define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        statistic: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    statistic_url: 'rush/order_entrust/statistic',
                    table: 'rush_order_entrust',
                }
            });

            var table = $("#table");

            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                //今日总收益
                $("#profit_today").text(data.profit_today);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.statistic_url,
                pk: 'buyer_id',
                sortName: 'buyer_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'nickname', title: __('昵称'), operate: 'LIKE'},
                        {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
                        {field: 'profit_total', title: __('累计收益'), operate: false},
                        {field: 'profit_today', title: __('今日收益'), operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
